Skip to content

Type-erased Specializers #20192

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Draft
wants to merge 23 commits into
base: main
Choose a base branch
from
Draft

Conversation

ecoskey
Copy link
Contributor

@ecoskey ecoskey commented Jul 18, 2025

Add type-erased wrappers around Specializer and SpecializerKey

Currently, type-erased materials have their key type and key getter located in AsBindGroup, and their specialize fn located in Material. This is mostly an experiment, but I think erased specializers might be a good way to wrap all that logic up nicely.

Vaguely what I'm imagining:

trait AsBindGroup {
-  type Data;
-  fn bind_group_data(&self);
}

trait Material {
-  fn specialize(...);
+  fn specializer() -> MaterialSpecializer {
+    MaterialSpecializer::new(
+      MySpecializer,
+      |material, mesh_key| MyKey(...),
+  }
}

Currently there's more boxing than there should be, I'll probably switch to some form of bytemuck or SmallBox later

@ecoskey ecoskey added A-Rendering Drawing game state to the screen C-Usability A targeted quality-of-life change that makes Bevy easier to use D-Modest A "normal" level of difficulty; suitable for simple features or challenging fixes labels Jul 18, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-Rendering Drawing game state to the screen C-Usability A targeted quality-of-life change that makes Bevy easier to use D-Modest A "normal" level of difficulty; suitable for simple features or challenging fixes
Projects
Status: No status
Development

Successfully merging this pull request may close these issues.

1 participant